package com.example.api.controller;

import com.example.api.dto.UserDTO;
import com.example.api.entity.User;
import com.example.api.serveice.Response;
import com.example.api.serveice.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class UserController {


    @Autowired
    private UserService userService;

    @GetMapping("/api/user")
    public Response<List<UserDTO>> userfindAll(){
         return Response.newSuccess(userService.getUserAll()) ;
 }

   @PostMapping("/api/user/adduser")
    public Response<User> addUser(@RequestBody User user){
        return Response.newSuccess(userService.addUser(user));
   }
}
